package co.com.coomeva.adminEvaluacion.modelo.persistencia;

import java.util.Date;
import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.criterion.Example;

import co.com.coomeva.adminEvaluacion.modelo.entidades.EdEvaluacion;

/**
 * A data access object (DAO) providing persistence and search support for
 * EdEvaluacion entities. Transaction control of the save(), update() and
 * delete() operations can directly support Spring container-managed
 * transactions or they can be augmented to handle user-managed Spring
 * transactions. Each of these methods provides additional information for how
 * to configure it for the desired type of transaction control.
 * 
 * @see co.com.coomeva.adminEvaluacion.modelo.entidades.EdEvaluacion
 * @author MyEclipse Persistence Tools
 */

public class EdEvaluacionDAO extends BaseHibernateDAO {
	private static final Log log = LogFactory.getLog(EdEvaluacionDAO.class);
	// property constants
	public static final String ESTADO = "estado";
	public static final String COD_CARGO = "codCargo";
	public static final String COD_CARGO_JEFE = "codCargoJefe";
	public static final String CARGO_JEFE = "cargoJefe";
	public static final String JEFE_CODIGO = "jefeCodigo";
	public static final String EMP_CARGO = "empCargo";
	public static final String COD_CIUDAD = "codCiudad";
	public static final String EMP_ROL_CODIGO = "empRolCodigo";

	public void save(EdEvaluacion transientInstance) {
		log.debug("saving EdEvaluacion instance");
		try {
			getSession().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}

	public void delete(EdEvaluacion persistentInstance) {
		log.debug("deleting EdEvaluacion instance");
		try {
			getSession().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	public EdEvaluacion findById(java.lang.Long id) {
		log.debug("getting EdEvaluacion instance with id: " + id);
		try {
			EdEvaluacion instance = (EdEvaluacion) getSession()
					.get(
							"co.com.coomeva.adminEvaluacion.modelo.entidades.EdEvaluacion",
							id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List findByExample(EdEvaluacion instance) {
		log.debug("finding EdEvaluacion instance by example");
		try {
			List results = getSession()
					.createCriteria(
							"co.com.coomeva.adminEvaluacion.modelo.entidades.EdEvaluacion")
					.add(Example.create(instance)).list();
			log.debug("find by example successful, result size: "
					+ results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}

	public List findByProperty(String propertyName, Object value) {
		log.debug("finding EdEvaluacion instance with property: "
				+ propertyName + ", value: " + value);
		try {
			String queryString = "from EdEvaluacion as model where model."
					+ propertyName + "= ?";
			Query queryObject = getSession().createQuery(queryString);
			queryObject.setParameter(0, value);
			return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}

	public List findByEstado(Object estado) {
		return findByProperty(ESTADO, estado);
	}

	public List findByCodCargo(Object codCargo) {
		return findByProperty(COD_CARGO, codCargo);
	}

	public List findByCodCargoJefe(Object codCargoJefe) {
		return findByProperty(COD_CARGO_JEFE, codCargoJefe);
	}

	public List findByCargoJefe(Object cargoJefe) {
		return findByProperty(CARGO_JEFE, cargoJefe);
	}

	public List findByJefeCodigo(Object jefeCodigo) {
		return findByProperty(JEFE_CODIGO, jefeCodigo);
	}

	public List findByEmpCargo(Object empCargo) {
		return findByProperty(EMP_CARGO, empCargo);
	}

	public List findByCodCiudad(Object codCiudad) {
		return findByProperty(COD_CIUDAD, codCiudad);
	}

	public List findByEmpRolCodigo(Object empRolCodigo) {
		return findByProperty(EMP_ROL_CODIGO, empRolCodigo);
	}

	public List findAll() {
		log.debug("finding all EdEvaluacion instances");
		try {
			String queryString = "from EdEvaluacion";
			Query queryObject = getSession().createQuery(queryString);
			return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}

	public EdEvaluacion merge(EdEvaluacion detachedInstance) {
		log.debug("merging EdEvaluacion instance");
		try {
			EdEvaluacion result = (EdEvaluacion) getSession().merge(
					detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	public void attachDirty(EdEvaluacion instance) {
		log.debug("attaching dirty EdEvaluacion instance");
		try {
			getSession().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public void attachClean(EdEvaluacion instance) {
		log.debug("attaching clean EdEvaluacion instance");
		try {
			getSession().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}
}